﻿namespace YaP.Library.Extensions
{
    public static class CSharpTools
    {
        /// <summary>
        /// Swap this object with another one
        /// </summary>
        /// <param name="o1">Source object</param>
        /// <param name="o2">Destination object</param>
        public static void SwapWith(this object o1, object o2)
        {
            if (o1.GetType() != o2.GetType())
            {
                throw new System.InvalidOperationException("Target object has not the same type");
            }
            else
            {
                var SwapSpace = o1;
                o1 = o2;
                o2 = SwapSpace;
            }
        }
    }
}